
from collections import *

n = int(input())
q = deque()  # 创建队列
for i in range(n):
    w = list(map(int, input().split()))
    if len(w) == 2:
        a, b = w
        q.append(b)
    else:
        a = w[0]  # 需要注意，在这里是复制了一遍链表 M
        if a == 2:
            if q:  # 判断是否为空
                c = q.popleft()
                print(c)
            else:
                print('no')
        else:
            print(len(q))
